home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c,comp.lang.c.moderated
- Subject: Re: const pointer confusion...
- Date: 26 Mar 1996 18:59:59 -0600
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4ja3uf$pe8@solutions.solon.com>
- References: <4j06gm$7oa@solutions.solon.com> <4j41hs$nku@solutions.solon.com> <4j6354$3ge@solutions.solon.com>
- NNTP-Posting-Host: solutions.solon.com
-
- In article <4j6354$3ge@solutions.solon.com>,
- Kurt Watzka <watzka@stat.uni-muenchen.de> wrote:
- >nausikaa:/home/kurt/src> cc cicp.c
- >"cicp.c", line 6: invalid type combination
- >cc: acomp failed for cicp.c
- >nausikaa:/home/kurt/src> cat cicp.c
- >#include <stdio.h>
- >
- >int main()
- >{
- > int i = 42;
- > const int const *p = &i;
- >
- > printf("%d\n", *p);
- > return 0;
- >}
- >
- >I think I'd better get a new compiler, if it cannot compile such a
- >simple program.
- >
- >AFAIK, "const int const *p;" _indeed is_ a syntax error.
-
- No. It is a semantic error that some compilers will warn about. A the
- duplicate type qualifier isn't a problem, but it could indicate that the
- programmer intended to do something else.
-
- Your compiler is producing a misleading diagnostic. There is no invalid type
- combination here. The error is one of a redunant ``const'', which is not
- forbidden by the C language.
-
- Both ``const int *p'' and ``int const *p'' are equivalent. Try feeding these to
- your compiler and post the results. If it doesn't accept the latter, it has a
- problem. It may produce a warning about an unusual order between the type
- specifier and the type qualifier, but it should not fail to translate, IMHO.
-
-
- --
-